const express = require('express');
const cache = require('../lib/cache');
const { translateWord, translateWordQQ } = require('../fenbi');
const router = express.Router();

// API路由示例
router.get('/test', (req, res) => {
  res.json({
    message: 'API路由测试成功',
    data: {
      id: 1,
      name: '测试数据'
    }
  });
});

// 解释成语或词语
router.get('/fenbi/translate-word', async (req, res) => {
  // console.log(req.query);
  const result = await translateWord(req.query.word);
  res.json({
    message: '成语或词语解释成功',
    data: result
  });
  });

router.get('/fenbi/translate-word-qq', async (req, res) => {
    const result = await translateWordQQ(req.query.word);
    res.json({
      message: '成语或词语解释成功',
      data: result
    });
  });


// 获取成语数据
router.get('/fenbi/idiom-explain', async (req, res) => {
  // const result = await readExistingData();
  res.json({
    message: '成语数据获取成功',
    data: []
  });
});

module.exports = router;
